import numpy as np
from scipy.interpolate import lagrange
import matplotlib.pyplot as plt

x1 = [2,4,6]
y1 = [1,5,7]
ln = lagrange(x1,y1)
x = np.linspace(-20,300,100)
y = ln(x)
plt.rcParams['font.sans-serif'] = ['SimHei']  # 设置字体
plt.rcParams['axes.unicode_minus'] = False
plt.plot(x,y,color='red')
plt.title("罗坛作业")
plt.xlabel("x")
plt.ylabel("ln(x)")
plt.xticks(np.arange(-20,300,20))
for x,y in zip():
    print(x,y)
    plt.text(x, y, y, ha='center', fontsize=12)
    plt.text(x, y + 6, x, ha='center', fontsize=12, color='red')
plt.scatter(x,y,marker=".",color='black')
plt.grid(True)
# plt.tight_layout()
plt.show()


